<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:head>
        <title>Facelet Title</title>
        <!-- <link href="./resources/css/default.css" rel="stylesheet" type="text/css" />-->
         <h:outputStylesheet name="default.css" library="css" />
    </h:head>
    <h:body>
        <ui:composition>
            <h:form >
                <script type="text/javascript">
                    function focusState(xhr, status, args) {  
                       if(args.validationFailed || !args.success) {}
                       else document.getElementById(tofocus).focus();
                       return false;
                   }
                    
                </script>
                 <p:outputPanel autoUpdate="true">
                <p:toolbar >
                    <p:toolbarGroup align="left">
                        <p:commandButton value="#{bundle.btnPrint}" icon="ui-icon-document"
                                      action="#{loanReportBean.executeReport()}" ajax="false"    />                         
                        
                    </p:toolbarGroup>
                </p:toolbar>
                </p:outputPanel>
                <h:panelGrid  style="vertical-align: top" id="displayLoanreport"  cellpadding="0" columns="2" columnClasses="panelGridId,panelGridId">
                    <p:panel header="Jenis Laporan" style="margin: 0 0 0 0;width: 500px" >
                    
                        <p:dataTable var="rpt" value="#{loanReportBean.availableMenu}" selection="#{loanReportBean.selectedReport}" selectionMode="single"
                                     rowKey="#{rpt.menuId}" scrollable="true" scrollHeight="350">
                            <p:ajax event="rowSelect" 
                           update=":#{utilityBean.findClientId('pnlReportFilterLoan')}" />  
                             <p:column style="width:auto" rendered="false" >
                                <f:facet name="header">ID</f:facet>
                                <h:outputText value="#{rpt.menuId}" />
                            </p:column>
                            <p:column style="width:250px" sortBy="#{rpt.menuName}">
                                <f:facet name="header">Nama Laporan</f:facet>
                                <h:outputText value="#{rpt.menuName}" />
                            </p:column>
                        </p:dataTable>
                    </p:panel>
                    
                    <p:panel header="Filter">
                        <p:panelGrid styleClass="noBorders"  id="pnlReportFilterLoan" rendered="#{loanReportBean.selectedReport!=null}">
                            <p:row rendered="#{reportCfgBean.showComponent(loanReportBean.selectedReport.menuId, 'TRANSDATE1;')}">
                                <p:column><h:outputLabel value="Dari" /></p:column>                                
                                <p:column>: <p:calendar value="#{loanReportBean.reportFilter.transDate1}" pattern="dd/MM/yyyy" size="8" showOn="button"/></p:column>                                
                            </p:row>
                            <p:row rendered="#{reportCfgBean.showComponent(loanReportBean.selectedReport.menuId, 'TRANSDATE2;')}">
                                <p:column><h:outputLabel value="Sampai" /></p:column>                                
                                <p:column>: <p:calendar value="#{loanReportBean.reportFilter.transDate2}" pattern="dd/MM/yyyy" size="8" showOn="button" /></p:column>                                
                            </p:row>
                            <p:row rendered="#{reportCfgBean.showComponent(loanReportBean.selectedReport.menuId, 'CIF;')}">
                                <p:column><h:outputLabel value="#{bundle.cif}"/></p:column>                                
                                <p:column>: <p:inputText label="#{bundle.cif}" id="filCifLoanReport" value="#{loanReportBean.reportFilter.cif}"  />
                            &nbsp;<p:commandButton icon="ui-icon-search" iconPos="center" styleClass="btnSmall"
                                            update="footLoanReportLookupCust" 
                                            process="@this" immediate="true" 
                                            action="#{loanBean.showDialog('dlgLoanReportLookupCust')}">
                                        <f:setPropertyActionListener target="#{loanReportBean.showLookup}" value="#{true}" />
                                    </p:commandButton></p:column>                                
                            </p:row>
                            <p:row rendered="#{reportCfgBean.showComponent(loanReportBean.selectedReport.menuId, 'TRANSNO;')}">
                                <p:column><h:outputLabel value="#{bundle.loanNo}" /></p:column>                                
                                <p:column>: <p:inputText label="#{bundle.loanNo}" id="filLoanReportTransNo" value="#{loanReportBean.reportFilter.transNo}"  />
                                    &nbsp; <p:commandButton icon="ui-icon-search" iconPos="center" styleClass="btnSmall"
                                                     update=":#{utilityBean.findClientId('displayLoanReportLookup')}" 
                                        process="@this" immediate="true" oncomplete="dlgLoanReportLookupLoan.show();" >
                                        <f:setPropertyActionListener target="#{loanReportBean.showLookup}" value="#{true}" />
                                    </p:commandButton>
                                </p:column>
                            </p:row>
                            <p:row rendered="#{reportCfgBean.showComponent(loanReportBean.selectedReport.menuId, 'USER;')}">
                                <p:column><h:outputLabel value="#{bundle.user}" /></p:column>                                
                                <p:column>: <p:inputText label="#{bundle.user}" /></p:column>                                
                            </p:row>
                            <p:row rendered="#{reportCfgBean.showComponent(loanReportBean.selectedReport.menuId, 'MONTHYEAR;')}">
                                <p:column><h:outputLabel value="#{bundle.period}" /></p:column>                                
                                <p:column>: 
                                    <h:panelGroup >
                                        <p:selectOneMenu value="#{loanReportBean.reportFilter.month}" >
                                            <f:selectItems value="#{reportCfgBean.availableMonth}" />  
                                        </p:selectOneMenu>
                                        <p:spinner min="2012" size="4"  style="position:absolute" value="#{loanReportBean.reportFilter.year}" />
                                    </h:panelGroup>
                                </p:column>                                
                            </p:row>
                            <p:row rendered="#{reportCfgBean.showComponent(loanReportBean.selectedReport.menuId, 'PRODUCT;')}">
                                <p:column><h:outputLabel value= "#{bundle.loanprod}" /></p:column>                                
                                <p:column>: 
                                    <h:panelGroup >
                                        <p:selectOneMenu value="#{loanReportBean.reportFilter.productId}" label="#{bundle.loanprod}"                                             
                                                        style="width: 151px;">
                                            <f:selectItem itemLabel="#{bundle.Select} #{bundle.loanprod}"  itemValue="-1" />
                                                <f:selectItems value="#{loanBean.avaibleProduct}" />                                        
                                        </p:selectOneMenu>
                                    </h:panelGroup>
                                </p:column>                                
                            </p:row>
                            <p:row rendered="#{reportCfgBean.showComponent(loanReportBean.selectedReport.menuId, 'PAYOFFICE;')}">
                                <p:column><h:outputLabel value= "#{bundle.paypoint}"  /></p:column>                                
                                <p:column>: 
                                    <p:selectOneMenu value="#{loanBean.loan.paypoint}" id="loanPaypoint" label="#{bundle.paypoint}" 
                                            style="width: 258px;" var="p" converter="paypoint" >
                                    <f:selectItem rendered="#{loanBean.loan.paypoint!=null}" itemLabel="#{loanBean.loan.paypoint.paypointName}" itemValue="#{loanBean.loan.paypoint}" />
                                    <f:selectItems value="#{loanBean.avblPoint}" var="point" itemLabel="#{point.paypointName}" itemValue="#{point}" />
                                    <p:column>#{p.paypointNo}</p:column>
                                    <p:column>#{p.paypointName}</p:column>
                                </p:selectOneMenu>
                                </p:column>                                
                            </p:row>
                            
                           <p:row rendered="#{reportCfgBean.showComponent(loanReportBean.selectedReport.menuId, 'MARKETING;')}">
                                <p:column><h:outputLabel value="#{bundle.marketing}" /></p:column>                                
                                <p:column>: <h:inputHidden value="#{loanReportBean.reportFilter.marketingId}" id="filLoanReportMarketingId"/>
                                    <p:inputText readonly="true" label="#{bundle.marketing}" id="filLoanReportMarketing" value="#{loanReportBean.reportFilter.marketingName}"  />
                                    &nbsp; <p:commandButton icon="ui-icon-search" iconPos="center" styleClass="btnSmall"
                                                     update=":#{utilityBean.findClientId('displayMarketingReportLookup')}" 
                                        process="@this" immediate="true" oncomplete="dlgLoanReportLookupMarketing.show();" >
                                        <f:setPropertyActionListener target="#{loanReportBean.showLookup}" value="#{true}" />
                                    </p:commandButton>
                                </p:column>
                            </p:row>
                    </p:panelGrid>
                        </p:panel>
                </h:panelGrid>
            
             <!-- LOOK UP CUSTOMER -->
                <p:dialog header="#{bundle.Select} #{bundle.customer}" widgetVar="dlgLoanReportLookupCust" 
                          modal="true" appendToBody="true" closable="true" dynamic="true" >
                 
                    <p:ajax listener="#{loanReportBean.handleCloseLookup}" />
                    <h:form>
                    <h:panelGrid id="displayLoanReportLookup" rendered="#{loanReportBean.showLookup==true}" >

                            <ui:include src="../master/customer/searchCustomer.xhtml" >
                                <ui:param name="lookupCustComponenId" value="loanReport" />
                            </ui:include> 
                        
                        <h:panelGrid cellpadding="0" styleClass="pComBtnSTDR"  id="footLoanReportLookupCust">
                            <f:facet name="footer">
                                <p:commandButton value="#{bundle.btnOK}" icon="ui-icon-disk" immediate="true" 
                                                process="@this" update="filCifLoanReport"
                                                action="#{loanReportBean.prepareCif(searchCustomer.selectedData.cif)}"
                                                oncomplete="dlgLoanReportLookupCust.hide(); focusState(xhr, status, args);" />

                                <p:commandButton value="#{bundle.btnClose}" 
                                                 oncomplete="dlgLoanReportLookupCust.hide()" 
                                                 immediate="true" icon="ui-icon-document" process="@this" />
                            </f:facet>
                        </h:panelGrid>
                    </h:panelGrid>    
                    </h:form>
                </p:dialog>
               
            
            
            <!-- LOOK UP Loan -->
            <p:dialog header="#{bundle.Select} #{bundle.loanNo}" widgetVar="dlgLoanReportLookupLoan" closable="true" dynamic="true" appendToBody="true" modal="true" >
                    <p:ajax listener="#{loanReportBean.handleCloseLookup}" />
                    <h:form>
                        <h:panelGrid id="displayLoanReportLookup" rendered="#{loanReportBean.showLookup==true}">
                            <ui:include src="../loan/searchLoan.xhtml" >
                                <ui:param name="lookupLoanComponenId" value="loanreport" />
                                <ui:param name="loanApprovalUid" value="#{1}" />
                                <ui:param name="loanStatusLoan" value="#{3}" />
                            </ui:include> 

                            <h:panelGrid cellpadding="0" styleClass="pComBtnSTDR" >
                                <f:facet name="footer">
                                    <p:commandButton value="#{bundle.btnOK}" icon="ui-icon-disk" immediate="true" 
                                                    process="@this" update=":#{utilityBean.findClientId('filLoanReportTransNo')}"
                                                    action="#{loanReportBean.prepareTransNo(searchLoanBean.selectedData.loanNo)}" 
                                                    oncomplete="dlgLoanReportLookupLoan.hide(); focusState(xhr, status, args);" />

                                    <p:commandButton value="#{bundle.btnClose}" oncomplete="dlgLoanReportLookupLoan.hide()" immediate="true" icon="ui-icon-document" process="@this" />
                                </f:facet>
                            </h:panelGrid>
                        </h:panelGrid>
                    </h:form>    
                </p:dialog>
            
            
             <!-- LOOK UP Marketing -->
             <p:dialog header="#{bundle.Select} #{bundle.marketing}" widgetVar="dlgLoanReportLookupMarketing" closable="true" dynamic="true" appendToBody="true" modal="true" >
                    <p:ajax listener="#{loanReportBean.handleCloseLookup}" />
                    <h:form>
                        <h:panelGrid id="displayMarketingReportLookup" rendered="#{loanReportBean.showLookup==true}">
                            <ui:include src="../loan/searchMarketing.xhtml" >
                                <ui:param name="lookupMarketingComponenId" value="loanreport" />
                                
                            </ui:include> 

                            <h:panelGrid cellpadding="0" styleClass="pComBtnSTDR" >
                                <f:facet name="footer">
                                    <p:commandButton value="#{bundle.btnOK}" icon="ui-icon-disk" immediate="true" 
                                                    process="@this" update=":#{utilityBean.findClientId('filLoanReportMarketing')} :#{utilityBean.findClientId('filLoanReportMarketingId')}"
                                                    action="#{loanReportBean.prepareMarketing(searchMarketingBean.selectedData.marketingId,searchMarketingBean.selectedData.marketingName)}" 
                                                    oncomplete="dlgLoanReportLookupMarketing.hide(); focusState(xhr, status, args);" />

                                    <p:commandButton value="#{bundle.btnClose}" oncomplete="dlgLoanReportLookupMarketing.hide()" immediate="true" icon="ui-icon-document" process="@this" />
                                </f:facet>
                            </h:panelGrid>
                        </h:panelGrid>
                    </h:form>    
                </p:dialog>
          </h:form>
        </ui:composition>
    </h:body>
</html>

